#ifdef TEST_PROC

#include <iostream>

#include "../../Shared/Shared.hpp"

int piping_test()
{
  while(1)
  {
    std::string str;
    std::cin >> str;
    if(str == "break")
      break;
    std::cout << "The child process received: " << str << std::endl;
  }

  return 0;
}

int test_cmdline_args(int argc,char *argv[])
{
  assert(argc == 2);
  assert(strcmp(argv[0],"c:\\windows\\\"file name\".txt") == 0);
  assert(strcmp(argv[1],"   ") == 0);

  return 0;
}

int main(int argc,char *argv[])
{
  for(int i = 0;i < argc;i++)
  {
    if(argv[i][0] == '-' && argv[i][1] == 'r')
    {
      // We are testing the return value. This return value the calling 
      // process expect is specified on the command line, in the form:
      // -r123
      return BuildNG::parse_int(argv[i] + 2);
    }
    else if(strcmp(argv[i],"-test_piping") == 0)
    {
      return piping_test();
    }
    else if(strcmp(argv[i],"-test-cmdline-args") == 0)
    {
      return test_cmdline_args(argc - i - 1,argv + i + 1);
    }
  }

  return -1;
}

#endif
